Repository navigation
feat(prompt-hook): gate context injection by confidence tier - #145
Merged
Merged
Conversation
Ports the non-telemetry prompt-hook improvements from upstream colby
1.2.0..1.4.1. `codegraph prompt-hook` was a bare forwarder that ran
codegraph_explore on every prompt; it now decides how much context to inject
by a three-tier confidence gate, so ordinary chatter no longer triggers a full
explore and non-code prompts stay silent.
- HIGH — a structural question (multilingual gate covering ~29 languages, with
inflections and multi-word phrases, and the call/trace/affect/connect stems
bounded on the right so callus/Connecticut/affectionate don't fire) OR a
graph-verified code token (inner camelCase, flanked underscore, call form
name(, or member access x.name; a bare PascalCase word is not a token) →
full explore in a <codegraph_context> block.
- MEDIUM — plain prose words that match indexed symbol-name segments
(one name covering >=2 prompt words, or a rare >=4-char segment shared across
>=2 names) → a short pointer naming the symbols for the agent to query
itself, never a full explore.
- otherwise silent.
The segment matching is derived at query time from the existing indexed node
names, so no schema change is needed (CURRENT_SCHEMA_VERSION stays 7 and the
golden .schema is byte-identical). The Claude UserPromptSubmit JSON payload
{prompt,cwd} is now parsed (raw-string invocation still works), and
CODEGRAPH_NO_PROMPT_HOOK / CODEGRAPH_PROMPT_HOOK=0 disable the hook.
No telemetry, counters, or tracking of any kind are added. The only new
dependency is unicode-normalization (NFD folding so accented prose matches
ASCII identifier segments); regex was already present transitively. Golden
fixtures and .schema unchanged (no regen).
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (94.33%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage. @@ Coverage Diff @@
## main #145 +/- ##
==========================================
- Coverage 95.55% 95.54% -0.01%
==========================================
Files 115 118 +3
Lines 57429 57929 +500
==========================================
+ Hits 54876 55349 +473
- Misses 2553 2580 +27
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upstream-sync DEFER item F — ports the non-telemetry prompt-hook improvements from colby 1.2.0..1.4.1 (#1126 multilingual gate, #1138 stem bounding, #1136 graph-tier mechanics, #1144/#1145/#1146 segment integrity), as ONE golden-neutral
feat:release. All telemetry EXCLUDED (maintainer decision — no-tracking posture).codegraph prompt-hookwas a bare forwarder that rancodegraph_exploreon every prompt. It now injects context by a three-tier confidence gate:call/trace/affect/connectstems bounded on the right socallus/Connecticut/affectionatedon't fire) OR a graph-verified code token (inner camelCase / flanked underscore / callname(/ memberx.name; bare PascalCase is not a token) → full explore in a<codegraph_context>block.Segment matching is derived at query time from existing indexed node names → no schema change (
CURRENT_SCHEMA_VERSIONstays 7, golden.schemabyte-identical, noname_segment_vocabtable). Parses the Claude UserPromptSubmit JSON{prompt,cwd}(raw-string invocation still works);CODEGRAPH_NO_PROMPT_HOOK/CODEGRAPH_PROMPT_HOOK=0disable it.Verification
make cigreen (fmt + clippy + test + guardrail);schema_parity4/4; equivalence 10/10.what calls Counter()fires + ordinary-word negatives, JSON payload, Tier-A/Tier-B MEDIUM on a dedicated non-golden fixture, kill-switch)..schema+ fixtures byte-identical, NO regen.unicode-normalization(NFD folding;regexalready transitive) — guardrail clean (not AI/vector/LLM).DEFER item F of the 1.2.0→1.4.1 upstream sync. Remaining: language expansions (Metal/CUDA, then from-scratch grammars).